﻿using System;

namespace ConsoleApp5
{
    public class Program
    {
    
        public static int Max1(int[] a)
            {
            int sum0;
            int maxsum = 0;
                for (int i = 0; i < a.Length; i++)
                {
                sum0 = 0;
                    for (int j = i; j < a.Length; j++) 
                    {
                        sum0 = sum0 + a[j];
                    if (sum0 > maxsum) {
                        maxsum = sum0;
                    }
                     }
                }
            return maxsum;
            }
        
        static void Main(string[] args)
        {
            int[] a = { 1, -4, 6, -4, 7, 5 };
            int b;
           
            b = Max1(a);
            Console.WriteLine(b);
            Console.ReadLine();
            

           
        }
    }
}
